
project(utility LANGUAGES CXX)

add_library(${PROJECT_NAME} STATIC)

## Compilation options
target_include_directories(${PROJECT_NAME} BEFORE PUBLIC ${CMAKE_SOURCE_DIR})
target_include_directories(${PROJECT_NAME} BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/utility)
target_include_directories(${PROJECT_NAME} BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

## Sources - common
set(UTILITY_SOURCES_COMMON
    constants.h
    colors.h
    loghandler.h
    utils.h
    utils.cpp
)
list(APPEND UTILITY_SOURCES ${UTILITY_SOURCES_COMMON})
source_group("Common" FILES ${UTILITY_SOURCES_COMMON})
target_sources(${PROJECT_NAME} PRIVATE ${UTILITY_SOURCES_COMMON})

## Sources - tasks
set(UTILITY_SOURCES_TASKS
    tasks/task.h
    tasks/task.cpp
    tasks/taskmanager.h
    tasks/taskmanager.cpp
)
list(APPEND UTILITY_SOURCES ${UTILITY_SOURCES_TASKS})
source_group("Tasks" FILES ${UTILITY_SOURCES_TASKS})
target_sources(${PROJECT_NAME} PRIVATE ${UTILITY_SOURCES_TASKS})

## Sources - widgets
set(UTILITY_SOURCES_WIDGETS
    widgets/loadingwidget.h
    widgets/loadingwidget.cpp
    widgets/logview.h
    widgets/logview.cpp
)
list(APPEND UTILITY_SOURCES ${UTILITY_SOURCES_WIDGETS})
source_group("Widgets" FILES ${UTILITY_SOURCES_WIDGETS})
target_sources(${PROJECT_NAME} PRIVATE ${UTILITY_SOURCES_WIDGETS})

## Sources - dpkg
set(UTILITY_SOURCES_DPKG
    dpkg/dpkg-db.h
    dpkg/dpkg-db.cpp
    dpkg/dpkg.h
    dpkg/dpkg.cpp
)
list(APPEND UTILITY_SOURCES ${UTILITY_SOURCES_DPKG})
source_group("Dpkg" FILES ${UTILITY_SOURCES_DPKG})
target_sources(${PROJECT_NAME} PRIVATE ${UTILITY_SOURCES_DPKG})
